<?php
include_once '../tools/common.php';
include_once '../tools/DbTools.php';
$is_login = getLoginStatus();
if(!$is_login){
    echo '尚未登入，<a href="../manage/adminloginUi.php">请登入</a>';
    die;
}else{
    DbTools::InitDb();
    $sql = "select * from accountinfo a inner JOIN bankcard b  on a.AccountId=b.AccountId";
    $result = DbTools::select($sql);
    //关闭连接
    DbTools::close();

}
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>卡列表</title>
</head>
<body>
<p><a href="../manage/adminInfo.php">回到管理员中心</a></p>

<form action="" method="post">
    <table border="1" cellspacing="0" cellpadding="10px">
        <tr>
            <th><input type="checkbox" onclick="checkAll(event);"></th>
            <th>序号</th>
            <th>身份证号码</th>
            <th>名字</th>
            <th>电话号码</th>
            <th>卡号</th>
            <th>密码</th>
            <th>余额</th>
            <th>状态</th>
        </tr>
        <?php
        foreach ($result as $key => $item){
            if($item['CardState']==0){
                $item['CardState']='正常';
            }else{
                $item['CardState']='已注销';
            }
            ?>
            <tr>
                <td><input type="checkbox" name="cardCheck[]" value="<?php echo $item['AccountId'];?>"></td>
                <td><?php echo $key+1;?></td>
                <td><?php echo $item['AccountCode'];?></td>
                <td><?php echo $item['RealName'];?></td>
                <td><?php echo $item['AccountPhone'];?></td>
                <td><?php echo $item['CardNo'];?></td>
                <td><?php echo $item['CardPwd'];?></td>
                <td><?php echo $item['CardMoney'];?></td>

                <td><?php echo $item['CardState'];?></td>
            </tr>
            <?php
        }
        ?>
    </table>
</form>
</body>
<script>
    function checkAll(event) {
        var checkStatus = event.target.checked;
        var allCards = document.getElementsByName('cardCheck[]');
        for(var i=0;i<allCards.length;i++){
            allCards[i].checked = checkStatus;
        }
    }
</script>
</html>